<!-- 首页，支持店铺装修 -->
<template>
	<view v-if="template">
		<s-layout title="首页"
              navbar="custom"
              tabbar="/pages/index/index"
              >
			<!-- 	<s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
          <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
        </s-block> -->

			<!-- <s-block styles="">
        <s-block-item type="" styles="" data=""></s-block-item>
      </s-block> -->

			<view class="home">
				<view class="topBox">
					<view class="title">
						<view class="title-top">
							<view class="shopName">
								欢迎加入<span>梦想体彩店</span>
							</view>
						</view>
					</view>

					<view class="Box">
						<view class="right-icon ">
							<span>分享好友</span>
						</view>
					</view>
				</view>
			</view>


			<view class="template">
				<view class="content">
					<view class="game-list">
						<view class="gameOneBox">
							<view class="game-item" @tap="gotoJingcai">
								<image src="@/static/index/football.png"></image>
								<view class="textBox">
									<view class="p1">竞彩足球</view>
									<view class="p2">17场赛事可投</view>
								</view>
							</view>
							<view class="game-item" @tap="gotoJingcaiBaskatball">
								<image src="@/static/index/basketball.png"></image>
								<view class="textBox">
									<view class="p1">竞彩篮球</view>
									<view class="p2">8场赛事可投</view>
								</view>
							</view>
							<view class="game-item" @tap="gotoZucaiSfc">
								<image src="@/static/index/sfc.png"></image>
								<view class="textBox">
									<view class="p1">胜负彩</view>
									<p class="p2">最高中<text style="color: red;">500万</text></p>
									
								</view>
							</view>
							<view class="game-item" @tap="gotoRenjiu">
								<image src="@/static/index/ren9.png"></image>
								<view class="textBox">
									<view class="p1">任九</view>
									<p class="p2">最高中<text style="color: red;">500万</text></p>
								</view>
							</view>
						</view>

						<view class="gameTwoBox">
							<view class="game-item" @tap="gotoRenjiu">
								<image src="@/static/index/sichangball.png"></image>
								<view class="textBox">
									<view class="p1">4场进球彩</view>
									<p class="p2">最高中<text style="color: red;">500万</text></p>
								</view>
							</view>
							<view class="game-item" @tap="gotoRenjiu">
								<image src="@/static/index/qichangball.png"></image>
								<view class="textBox">
									<view class="p1">6场半全场</view>
									<p class="p2">最高中<text style="color: red;">500万</text></p>
								</view>
							</view>
						</view>
						
						<view class="gameOneBox">
							<view class="game-item" @tap="gotoPl3d">
								<image src="@/static/index/pls.png"></image>
								<view class="textBox">
									<view class="p1">排列三</view>
									<p class="p2">今晚<text style="color: red;">21:00</text>停止</p>
								</view>
							</view>
							<view class="game-item" @tap="gotoPl3d">
								<image src="@/static/index/plw.png"></image>
								<view class="textBox">
									<view class="p1">排列五</view>
									<p class="p2">今晚<text style="color: red;">21:00</text>停止</p>
								</view>
							</view>
							<view class="game-item" @tap="gotoPl3d">
								<image src="@/static/index/qxc.png"></image>
								<view class="textBox">
									<view class="p1">七星彩</view>
									<p class="p2">今晚<text style="color: red;">21:00</text>停止</p>
								</view>
							</view>
							<view class="game-item" @tap="gotoRenjiu">
								<image src="@/static/index/daletou.png"></image>
								<view class="textBox">
									<view class="p1">大乐透</view>
									<p class="p2">今晚<text style="color: red;">21:00</text>停止</p>
								</view>
							</view>
						</view>
					</view>
				</view>
				<uni-view class="content"></uni-view>
				<uni-view class="act-area">
					<div class="act-area-left">
						<uni-image class="image1">
							<div
								style="background-image: url('../../static/index/trend.png'); background-position: 0% 0%; background-size: 100% 100%; background-repeat: no-repeat;">
							</div>
							<img src="@/static/index/trend.png" draggable="false">
						</uni-image>
					</div>
					<div class="act-area-right">
						<uni-image class="image1" style="height: 64px;">
							<div
								style="background-image: url('../../static/index/kjgg.png'); background-size: 100% 100%; background-repeat: no-repeat;">
							</div>
							<uni-resize-sensor>
								<div>
									<div></div>
								</div>
								<div>
									<div></div>
								</div>
							</uni-resize-sensor>
							<img src="@/static/index/kjgg.png" draggable="false">
						</uni-image>
						<uni-image class="image1" style="height: 64px;">
							<div
								style="background-image: url('../../static/index/kjgg.png'); background-size: 100% 100%; background-repeat: no-repeat;">
							</div>
							<uni-resize-sensor>
								<div>
									<div></div>
								</div>
								<div>
									<div></div>
								</div>
							</uni-resize-sensor>
							<img src='@/static/index/kjgg.png' draggable="false">
						</uni-image>
					</div>
				</uni-view>
			</view>
		</s-layout>
	</view>
</template>

<script setup>
	import {
		computed,
	} from 'vue';
	import {
		onLoad,
		onPageScroll,
		onPullDownRefresh,
	} from '@dcloudio/uni-app';
	import sheep from '@/sheep';
	import $share from '@/sheep/platform/share';
	// 隐藏原生tabBar
	uni.hideTabBar();

	const template = computed(() => sheep.$store('app').template?.home);
	// 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里
	// (async function() {
	// console.log('原代码首页定制化数据',template)
	// let {
	// 	data
	// } = await index2Api.decorate();
	// console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value))
	// 改变首页底部数据 但是没有通过数组id获取商品数据接口
	// let {
	// 	data: datas
	// } = await index2Api.spids();
	// template.value.data[9].data.goodsIds = datas.list.map(item => item.id);
	// template.value.data[0].data.list = JSON.parse(data[0].value).map(item => {
	// 	return {
	// 		src: item.picUrl,
	// 		url: item.url,
	// 		title: item.name,
	// 		type: "image"
	// 	}
	// })
	// }())

	// 前往排列三选购页面
	function gotoPl3d() {
		sheep.$router.go('/pages/pailie/pl3d/pl3d');
	};
	// 前往竞猜足球选购页面
	function gotoJingcai() {
		sheep.$router.go('/pages/jingcai/football/football');
	};
	// 前往竞猜篮球选购页面
	function gotoJingcaiBaskatball() {
		sheep.$router.go('/pages/jingcai/basketball/basketball');
	};
	// 前往足彩胜负彩选购页面
	function gotoZucaiSfc() {
		sheep.$router.go('/pages/zucai/sfc/sfc');
	};
	// 前往任选九选购页面
	function gotoRenjiu() {
		sheep.$router.go('/pages/zucai/sfc/renjiu');
	};
	onLoad((options) => {
		// #ifdef MP
		// 小程序识别二维码
		if (options.scene) {
			const sceneParams = decodeURIComponent(options.scene).split('=');
			console.log('sceneParams=>', sceneParams);
			options[sceneParams[0]] = sceneParams[1];
		}
		// #endif

		// 预览模板
		if (options.templateId) {
			sheep.$store('app').init(options.templateId);
		}

		// 解析分享信息
		if (options.spm) {
			$share.decryptSpm(options.spm);
		}

		// 进入指定页面(完整页面路径)
		if (options.page) {
			sheep.$router.go(decodeURIComponent(options.page));
		}
	});

	// 下拉刷新
	onPullDownRefresh(() => {
		sheep.$store('app').init();
		setTimeout(function() {
			uni.stopPullDownRefresh();
		}, 800);
	});

	onPageScroll(() => {});
</script>

<style>
	* {
		margin: 0;
		-webkit-tap-highlight-color: transparent;
	}

	uni-resize-sensor {
		display: block;
		z-index: -1;
		visibility: hidden;
		-webkit-animation: once-show 1ms;
		animation: once-show 1ms;
	}

	uni-resize-sensor,
	uni-resize-sensor>div {
		position: absolute;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		overflow: hidden;
	}

	.act-area .act-area-right .image1:first-child {
		margin-bottom: 10px;
	}

	.act-area .act-area-right .image1 {
		width: 152px;
		height: 64px;
	}

	.act-area .act-area-right {
		flex: 1;
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: center;
	}

	uni-image>img {
		-webkit-touch-callout: none;
		-webkit-user-select: none;
		-moz-user-select: none;
		display: block;
		position: absolute;
		top: 0;
		left: 0;
		opacity: 0;
	}

	uni-image>div,
	uni-image>img {
		width: 100%;
		height: 100%;
	}

	.act-area .act-area-left .image1 {
		width: 152px;
		height: 138px;
	}

	.act-area .act-area-left {
		flex: 1;
	}

	.act-area {
		margin: 0 15px 10px;
		display: flex;
		justify-content: space-between;
		flex-wrap: nowrap;
		flex-direction: row;
		align-items: center;
		box-sizing: border-box;
		background: #fff;
		border-radius: 8px;
		height: 168px;
		padding: 15px;
	}

	.home .topBox {
		background: linear-gradient(180deg, #fff1f1, rgba(198, 224, 255, 0));
		position: relative;
	}

	.home .topBox .title {
		position: relative;
		z-index: 99999999999999;
		margin: 0 16px;
		padding-top: 20px;
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
		flex-direction: row;
		flex-wrap: nowrap;
	}

	.home .topBox .title .title-top {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		position: relative;
	}

	.home .topBox .title .title-top .shopName {
		font-style: italic;
		height: 27px;
		font-size: 20px;
		font-weight: 600;
		color: #000;
	}

	.home .topBox .title .title-top .shopName span {
		color: #ff3d00;
	}

	.home .topBox .Box {
		margin: 16px 15px 15px;
		height: 150px;
		background: url(@/static/homeBannerBg.png) no-repeat;
		background-size: 100% 100%;
		position: relative;
	}

	.home .topBox .Box .right-icon {
		background: linear-gradient(180deg, #fee8bf, #ffd882);
		opacity: 1;
		border-radius: 46px;
		width: 80px;
		height: 28px;
		position: absolute;
		bottom: 14px;
		left: 18px;
		text-align: center;
	}

	.notice {
		width: 100%;
		display: flex;
		justify-content: center;
		padding: 0px 15px;
		box-sizing: border-box;
	}

	.game-list {
		display: flex;
		flex-wrap: nowrap;
		align-items: flex-start;
		flex-direction: column;
		margin: 15px 15px 15px;
		padding: 20px 9px;
		border-radius: 10px;
		background: #fff;
		box-sizing: border-box;
		position: relative;
		margin-top: 15px;
	}

	.game-list .gameOneBox {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: space-between;
		width: 100%;
		border-bottom: 1px solid #ebebeb;
	}

	.game-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		border-right: 1px solid #ebebeb;
		flex: 0 0 25%;
		box-sizing: border-box;
	}

.gameOneBox .game-item:last-child {
    border-right: 1px solid transparent;
}

	.game-item uni-image {
		width: 44px;
		height: 44px;
	}

	uni-image {
		width: 320px;
		height: 240px;
		display: inline-block;
		overflow: hidden;
		position: relative;
	}

	.p1 {
		color: #000;
		margin-top: 8px;
		font-size: 14px;
	}

	.p2 {
		font-size: 10px;
		color: #666;
		margin-top: 4px;
		text-align: center;
		white-space: nowrap;
	}

	p {
		display: block;
		margin-block-start: 1em;
		margin-block-end: 1em;
		margin-inline-start: 0px;
		margin-inline-end: 0px;
	}

	.game-list .gameTwoBox {
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		justify-content: space-between;
		width: 100%;
		border-bottom: 1px solid #ebebeb;
		box-sizing: border-box;
	}

	.gameTwoBox .game-item {
		display: flex;
		flex-direction: row;
		align-items: center;
		border-right: 1px solid #ebebeb;
		flex: 0 0 50%;
		box-sizing: border-box;
		padding: 10px 5px;
		justify-content: flex-start;
	}
.gameTwoBox .game-item:last-child {
    border-right: 1px solid transparent;
}
	.game-list .gameThreeBox {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		width: 100%;
		position: relative;
	}

	.gameThreeBox .game-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		border-right: 1px solid #ebebeb;
		flex: 0 0 33%;
		box-sizing: border-box;
		padding: 10px 5px;
		justify-content: flex-start;
		border-bottom: 1px solid #ebebeb;
		border-top: 1px solid transparent;
	}
.gameThreeBox .game-item:nth-child(3) {
    border-right: 1px solid transparent;
    border-top: 1px solid transparent;
}
	.game-item .textBox {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: center;
		margin-bottom: 5px;
	}
</style>